import os
from datetime import datetime, timedelta

# 获取今天的日期
today = datetime.today()

# 生成前一周的日期列表
dates = [(today - timedelta(days=i)).strftime("%Y-%m-%d") for i in range(7)]

# 设置小时和分钟
start_hour = 8
end_hour = 17
start_minute = 0
end_minute = 59

# 获取当前目录下的所有子目录
def get_subdirectories():
    """获取当前目录下的所有子目录"""
    return [d for d in os.listdir() if os.path.isdir(d)]

# 获取当前目录下的所有子目录
subdirs = get_subdirectories()

# 遍历所有日期和子目录
for date in dates:
    for subdir in subdirs:
        # 拼接完整路径
        dir_path = os.path.join(subdir)

        # 确保目录存在
        if not os.path.exists(dir_path):
            print(f"Directory {dir_path} does not exist, skipping...")
            continue

        # 初始时间
        start_time = datetime.strptime(f"{date} {start_hour:02d}:{start_minute:02d}:00", "%Y-%m-%d %H:%M:%S")
        end_time = datetime.strptime(f"{date} {end_hour:02d}:{end_minute:02d}:59", "%Y-%m-%d %H:%M:%S")

        # 遍历每一分钟生成文件
        current_time = start_time
        while current_time <= end_time:

            # 格式化时间戳
            filename = current_time.strftime("%Y-%m-%d-%H-%M-%S.mp4")
            file_path = os.path.join(dir_path, filename)

            # 创建空文件
            with open(file_path, 'w') as f:
                pass  # 空文件

            print(f"Created file: {file_path}")

            # 格式化时间戳
            filename = current_time.strftime("%Y-%m-%d-%H-%M-%S.mp4.tmp")
            file_path = os.path.join(dir_path, filename)

            # 创建空文件
            with open(file_path, 'w') as f:
                pass  # 空文件

            print(f"Created file: {file_path}")

            # 增加一分钟
            current_time += timedelta(minutes=1)
